Skip to content

fix: respect line boundaries in text input shortcuts - #17460

Merged
Siedlerchr merged 20 commits into
JabRef:mainfrom
Gautam-aman:fix/17256-line-shortcuts
Nov 7, 2026
Merged

Siedlerchr merged 20 commits into
JabRef:mainfrom
Gautam-aman:fix/17256-line-shortcuts

Conversation

@Gautam-aman

@Gautam-aman Gautam-aman commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes beginning-of-line, end-of-line, and kill-line keyboard shortcuts in multiline text fields such as Abstract and Comment.

Previously, line-navigation shortcuts behaved like document-navigation shortcuts, while kill-line removed all text after the caret, including subsequent lines.

This change separates line and document navigation, restricts line editing to newline-delimited boundaries, and preserves existing single-line text field behavior.

Analogies: Like navigating within a single paragraph instead of jumping to the beginning or end of an entire document, this change keeps text-editing shortcuts focused on the current line.

Steps to test

  1. Open JabRef on macOS and select an entry containing a multiline Abstract or Comment field.
  2. Open Preferences → Keyboard shortcuts and assign beginning-of-line, end-of-line, and kill-line to Ctrl + A, Ctrl + E, and Ctrl + K, respectively.
  3. Place the caret in the middle of the second line and verify that Ctrl + A moves it to the beginning of that line without jumping to the beginning of the entire field.
  4. Press Ctrl + E and verify that the caret moves to the end of the current line without jumping to the end of the entire field.
  5. Press Ctrl + K from the middle of a line and verify that only the remaining characters on that line are removed, preserving subsequent lines.
  6. Press Ctrl + K at the end of a line and verify that the newline is removed, joining the next line.
  7. Verify that beginning-of-text and end-of-text shortcuts still navigate to the beginning and end of the entire field.
  8. Verify that shortcuts retain their expected behavior in single-line text fields and that existing Source-tab navigation remains unaffected.

Screenshot of the shortcut result: pending.

Core-library checks, focused keyboard-binding tests, Checkstyle, Modernizer, OpenRewrite, Javadoc, Markdown lint, and textlint passed locally.

Related issues and pull requests

Closes #17256

Related: #17415 (previously closed without merging).

AI usage

ChatGPT assisted with tests, debugging, and the initial PR text.

AI CHECKLIST.md walkthrough

Code checklist

[!IMPORTANT]
This is a mandatory final gate. When the implementation is finished and before you open a PR, work through every box below and tick it. If a box cannot be ticked, fix the code first; mark a box [/] only if the point genuinely does not apply.

AGENTS.md describes how to write code while developing — this file confirms the finished result. Do not skip the checklist and do not skip individual points.

1. Code self-review

Read your own diff once, top to bottom, and confirm each point.

Nullability and control flow

  • No == null / != null checks — JSpecify annotations (@NullMarked, @Nullable, @NonNull) used instead.
  • No Objects.requireNonNull(...) — nullability expressed via JSpecify annotations.
  • New classes annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] New packages annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] Optional consumed with ifPresent / ifPresentOrElse / map / orElseThrow — never orElse(unusedValue) nor an isPresent() + get() block.
  • [/] StringUtil.isBlank(...) used instead of s == null || s.isBlank().

Exceptions

  • No catch (Exception e) — only specific exceptions are caught.
  • No throw new RuntimeException(...) / IllegalStateException(...) — these tear down the whole application.
  • [/] Logged exceptions are passed as the last logger argument (LOGGER.info("...", e)), not concatenated into the message string.

Style and idioms

  • [/] New BibEntry objects built with withers (withField, not setField).
  • Modern Java used: List.of() / Map.of() / Set.of(), Path.of(), SequencedCollection / SequencedSet, text blocks.
  • [/] Regexes use a precompiled Pattern.compile(...) constant, not String.matches(...).
  • Keep alphabetical ordering when adding variables or enum items.
  • [/] Background work uses org.jabref.logic.util.BackgroundTask, not new Thread().
  • No commented-out code, no trivial comments restating the code, no AI-disclosure comments in source.
  • [/] Markdown Javadoc (///) uses Markdown syntax, not JavaDoc inline tags: `code` instead of {@code}, [ClassName] instead of {@link}.

User-facing text

  • [/] All user-facing text localized (Localization.lang in Java, % prefix in FXML).
  • [/] Sentence case (not Title Case); no trailing !; labels do not end with :.
  • [/] Variance expressed with placeholders ("...: %0"), not string concatenation.

Security

  • [/] User-controlled data (request params, entry fields, file contents) is HTML-escaped before being written into any text/html response — including exception/error messages, not just the success body (XSS).

Tests

  • In case issue lists an example, this concrete example is covered by a test case.
  • Behavior changes in org.jabref.model / org.jabref.logic have added or updated tests.
  • Tests assert object contents (assertEquals), use plain JUnit asserts (not AssertJ), have no @DisplayName, do not catch exceptions (let them propagate so JUnit reports setup/teardown failures directly), and use @TempDir instead of manual temp directories.
  • [/] Fetcher tests hit the live endpoints — the remote API is not mocked or stubbed (automated-review suggestions to mock it are rejected on purpose).

2. Verification commands

Run in this order — cheapest first. Each must pass.

  • ./gradlew :jablib:check (or ./gradlew check for all modules).
  • ./gradlew checkstyleMain checkstyleTest checkstyleJmh.
  • ./gradlew modernizer.
  • ./gradlew --no-configuration-cache :rewriteDryRun reports no changes (run ./gradlew rewriteRun to fix).
  • ./gradlew javadoc.
  • npx markdownlint-cli2 "docs/**/*.md" "*.md" (only if Markdown changed).
  • npm ci && npm run textlint reports no misspellings (only if Markdown changed).
  • [/] Only if formatting is still off after rewriteRun: docker run -v $(pwd):/github/workspace ghcr.io/leventebajczi/intellij-format:master "*.java" "" ".idea/codeStyles/Project.xml".

3. Documentation

  • CHANGELOG.md entry added if the change is visible to the user (end-user wording, no extra blank lines, sorted in next to existing entries about the same component/feature). Link the issue if one exists; link the PR only when no issue exists. Use TODO as the placeholder when neither is known yet — never a fake number. No entry for fixes to changes that were themselves introduced after the last release (feature only in ## [Unreleased]) — update the existing unreleased entry instead if needed.
  • Searched jabref/issues and jabref-koppor/issues for a related issue; linked only on a confident match, otherwise kept TODO (no closes/fixes for merely-similar issues).
  • Requirement added to docs/requirements/<area>.md if the change is a new feature or significant bug fix (skip for refactors, minor fixes, and internal changes).
  • Developer documentation under docs/ updated if behavior or architecture changed.

4. Pull request

  • PR body built from .github/PULL_REQUEST_TEMPLATE.md, every section filled.
  • All checklist items kept and marked [x], [ ], or [/].
  • "Steps to test" is a numbered list with a cropped screenshot of the result for every visible change; no video (only allowed when another program is involved, e.g. drag and drop or push to an external application).
  • All HTML comments removed from the PR body.
  • PR created with gh pr create --body-file <file> (not --body).
  • [/] If CHANGELOG.md used a TODO placeholder (no issue confidently identified yet — an existing issue link always stays), the PR was opened as draft, the placeholder was replaced with the real PR-number link after PR creation, committed and pushed, and only then was the PR marked ready for review. If an issue is identified or created later, the link is switched to the issue.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I disclosed the exact model IDs, reviewed and understood the AI-assisted changes, and take full responsibility for them.
  • I manually tested the shortcuts in a running JabRef.
  • I added JUnit tests for the behavior change.
  • I added a cropped screenshot showing the result.
  • I added an end-user entry to CHANGELOG.md linked to the issue.
  • I checked the user documentation; the existing keyboard-shortcut setup instructions remain accurate.

Screenshot

Before — Incorrect line shortcut behavior

01-abstract-wrapped-start-caret-170 02-abstract-after-beginning-caret-0 03-abstract-after-end-caret-448 04-abstract-after-up-caret-0 05-abstract-after-down-caret-448 06-abstract-after-kill-line-caret-69 07-abstract-after-undo-caret-448 08-source-wrapped-start-paragraph-5-offset-143 09-source-after-beginning-paragraph-5-offset-115 10-source-after-end-paragraph-5-offset-222 11-source-after-up-paragraph-5-offset-0 12-source-after-down-paragraph-5-offset-366 13-source-after-kill-line-paragraph-5-offset-42 14-source-after-undo-paragraph-9-offset-0

After — Fixed line shortcut behavior

Beginning/end-of-line shortcuts now respect the current line boundaries. Kill-line removes only the remaining text on the current line, preserving subsequent lines.

01-abstract-wrapped-start-caret-170 02-abstract-after-beginning-caret-27 03-abstract-after-end-caret-393 04-abstract-after-up-caret-26 05-abstract-after-down-caret-420 06-abstract-after-kill-line-caret-69 07-abstract-after-undo-caret-393 08-source-wrapped-start-paragraph-5-offset-143 09-source-after-beginning-paragraph-5-offset-115 10-source-after-end-paragraph-5-offset-222 11-source-after-up-paragraph-5-offset-0 12-source-after-down-paragraph-5-offset-366 13-source-after-kill-line-paragraph-5-offset-42 14-source-after-undo-paragraph-5-offset-366

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Oct 14, 2026
@jabref-machine jabref-machine added the dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) label Oct 14, 2026
@github-actions github-actions Bot added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed status: changes-required Pull requests that are not yet complete labels Oct 14, 2026
@Siedlerchr
Siedlerchr requested a review from InAnYan October 14, 2026 11:38
@InAnYan

InAnYan commented Oct 15, 2026

Copy link
Copy Markdown
Member

@Gautam-aman , hi! Could you please specify how to do this:

"Configure beginning-of-line, end-of-line, and kill-line shortcuts as Control+A, Control+E, and Control+K, respectively."

It's not configured in JabRef by default?

@Gautam-aman

Copy link
Copy Markdown
Contributor Author

hey! You're right, they're not set by default. You can assign them manually under File → Preferences → Keyboard shortcuts.
I was referring to the shortcuts mentioned in the original issue (#17256). I Should've made that clearer in the testing steps. Thanks for pointing it out.

@InAnYan

InAnYan commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Ok, good! All shortcuts work (except the Ctrl-A, for some reason I couldn't test it because there was not possible to edit the action for it, there was no "Move to the beginning of the line").

Now rests the code review, which I will do later

UPD: I was able to test the beginning of the line, all good

@Gautam-aman

Copy link
Copy Markdown
Contributor Author

Great, thanks for testing and confirming! Glad everything's working. Looking forward to your feedback on the code review.

@LoayTarek5 LoayTarek5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @Gautam-aman, great work, also please add a CHANGELOG entry, remove the extra blank lines, and fill the checklist.
could you also please add like screenshots, or video to demonstrate

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Oct 17, 2026
@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Oct 18, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Oct 19, 2026
@Gautam-aman

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I’ve addressed the code and test feedback, added the changelog entry, and pushed the formatting fix.

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Oct 19, 2026
@Siedlerchr

Copy link
Copy Markdown
Member

Overall looks good but I found some issues while testing:

New regression: Kill line replaces the entire text value. In the global search field, Cmd + K deleted the rest of the line, but Cmd + Z could not restore it. Undo worked for ordinary typing in the same field. A range deletion would preserve the text control’s editing behavior; JavaFX distinguishes deleteText from setText. https://openjfx.io/javadoc/27/javafx.controls/javafx/scene/control/TextInputControl.html

Pre-existing issue: Move caret up/down calls home()/end(). In a multiline abstract, Cmd + P jumped from the last line to the start of the document.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Oct 31, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Nov 1, 2026
@qodo-code-review

qodo-code-review Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Resolved findings
1. Line movement requirement misleads tests ✓ Resolved
Description
The new requirement says Up and Down move between newline-delimited lines, but moveCaretUp and
moveCaretDown use visual-line movement for text areas. A new test expects Down to move to an
interior position in a wrapped paragraph with no newline, so future tests implementing the written
requirement would conflict with the behavior this PR establishes.

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions github-actions Bot added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 1, 2026
@Siedlerchr

Siedlerchr commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

The up/down shortcuts skip wrapped visual lines in multiline fields. For example, with a long Abstract paragraph, Ctrl+N moves to the next newline or blank line rather than the next visible line. In macOS TextEdit, Ctrl+N and Ctrl+P move one visible line at a time

I would say, this is a follow up task

@Siedlerchr

Copy link
Copy Markdown
Member

I now fixed the up/down behavior and also in the code area, otherwise it was already good!

@github-actions github-actions Bot removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 7, 2026
@Siedlerchr
Siedlerchr added this pull request to the merge queue Nov 7, 2026
@github-actions github-actions Bot added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers status: to-be-merged PRs which are accepted and should go into the merge-queue. and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 7, 2026
@Siedlerchr Siedlerchr mentioned this pull request Nov 7, 2026
25 of 30 tasks
Merged via the queue into JabRef:main with commit c88bfa9 Nov 7, 2026
83 of 84 checks passed
@jabref-machine

Copy link
Copy Markdown
Collaborator

Created backport PR for black-forest:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin port-17460-to-black-forest
git worktree add --checkout .worktree/port-17460-to-black-forest port-17460-to-black-forest
cd .worktree/port-17460-to-black-forest
git reset --hard HEAD^
git cherry-pick -x c88bfa998a90ac3d728068594ced605d33e55e32

@Gautam-aman

Copy link
Copy Markdown
Contributor Author

Hey @Siedlerchr, thanks for merging the PR!

I noticed the backport to black-forest has some conflicts. I'd be happy to help resolve them. Should I go ahead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: keybinding dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) size: big status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Beginning/end of line text editing shortcuts are not limited to a single line

5 participants